//
//  YXReleaseAleatView.m
//  CreditCard
//
//  Created by 杨旭 on 2018/1/21.
//  Copyright © 2018年 杨旭. All rights reserved.
//

#import "YXReleaseAleatView.h"
@interface YXReleaseAleatView ()
@property (weak, nonatomic) IBOutlet UIView *alertView;

@end

@implementation YXReleaseAleatView

-(instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        NSArray *viewArray = [[NSBundle mainBundle]loadNibNamed:@"YXReleaseAleatView" owner:self options:nil];
        self = viewArray[0];
        self.frame = frame;
        self.alertView.layer.masksToBounds = YES;
        self.alertView.layer.cornerRadius = 10.0f;
        
    }
    return self;
    
}


- (IBAction)closeBtnAction:(UIButton *)sender {
    
    [self removeFromSuperview];
}


#pragma mark - 弹出 -
- (void)showCustomAlertView {
    UIWindow *rootWindow = [UIApplication sharedApplication].keyWindow;
    [rootWindow addSubview:self];
    [self creatShowAnimation];
    
}

- (void)creatShowAnimation {
    
    self.alertView.layer.position = self.center;
    self.alertView.transform = CGAffineTransformMakeScale(0.90, 0.90);
    [UIView animateWithDuration:0.25 delay:0 usingSpringWithDamping:0.8 initialSpringVelocity:1 options:UIViewAnimationOptionCurveLinear animations:^{
        self.alertView.transform = CGAffineTransformMakeScale(1.0, 1.0);
    } completion:^(BOOL finished) {
        
    }];
    
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    self.alpha = 0;
}


@end
